<!DOCTYPE html>
<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>收款订单</title>
	</head>

	<body>
	<div class="layui-fluid">
		<div style="height:11px;"></div>
		<blockquote class="layui-elem-quote">
			<div class="layui-form">
				<div class="layui-form-item">
					<label class="layui-form-label">关键字</label>
					<div class="layui-input-inline">
						<input name="keywords" type="text"  class="layui-input" placeholder="输入会员名称、电话、订单单号" style=" width:215px" />
					</div>
					<label class="layui-form-label">订单状态</label>
					<div class="layui-input-inline">
						<select name="state" id="state" style=" width:100px">
							<option value="">--全部--</option>
							<option value="1" {if isset($getdata.state) && $getdata.state==1}selected{/if}>--交易成功--</option>
							<option value="2" {if isset($getdata.state) && $getdata.state==2}selected{/if}>--支付失败--</option>
							<option value="3" {if isset($getdata.state) && $getdata.state==3}selected{/if}>--支付中--</option>
							<option value="4" {if isset($getdata.state) && $getdata.state==4}selected{/if}>--代付中--</option>
							<option value="5" {if isset($getdata.state) && $getdata.state==5}selected{/if}>--代付失败--</option>
						</select>
					</div>

					<label class="layui-form-label">时间</label>
					<div class="layui-input-inline">
						<input type="text" name="query_date" id="query_date" autocomplete="off" class="layui-input" readonly="readonly">
					</div>
					<div class="layui-input-inline">
						<button class="layui-btn" lay-submit lay-filter="sub">查询</button>
					</div>
				</div>
			</div>
		</blockquote>

		<blockquote class="layui-elem-quote">
			以下所有数据在没有选择日期范围的时候就是总数据，如果选择日期范围那么就是日期范围内的总数据<br>
			成交额：<span id="total">0</span>元 <br>
			手续费：<span id="total_fee">0</span>元 <br>
			手续费利润：<span id="total_fee_profit">0</span>元<br>
			代付费：<span id="total_df">0</span>元<br>
			代付费利润：<span id="total_df_profit">0</span>元<br>
			总利润：<span id="total_profit">0</span>元<br>
		</blockquote>

		<div class="layui-btn-group" id="toolbar" style="display: none;">
			<!-- <button class="layui-btn" id="add" onclick="openWin('新增内容','{:url('add')}');"><i class="layui-icon">&#xe654;</i>增加</button>
            <button class="layui-btn" id="edit" onclick="openEditWin('{:url('edit')}','id');"><i class="layui-icon">&#xe642;</i>编辑</button> -->
			<button class="layui-btn" id="del" onclick="delItem('{:url('dels')}', 'id');"><i class="layui-icon">&#xe640;</i>批量删除
			</button>
		</div>

		<div id="table" lay-filter="table" class="layui-table"></div>


		<!-- tpl区域 -->
		<script type="text/html" id="bar">
			<a class="layui-btn layui-btn-xs" lay-event="query_state">查询状态</a>
		</script>


	</div>
	<link href="__PLUS__/layui/css/layui.css" rel="stylesheet"/>
	<script src="__PLUS__/layui/layui.js"></script>
	<script>
		layui.use(["jquery", "form", "layer", "table", "laydate"], function () {
			var $ = layui.jquery, layer = layui.layer, table = layui.table, form = layui.form,laydate=layui.laydate;

			laydate.render({
				elem:"#query_date",
				range:true
			});

			var options = {
				elem: '#table',
				url: "{:url('index')}", //数据接口
				cols: [[ //表头
					{type: "checkbox"},
					{field: 'records_id', title: 'ID'},
					{field: 'user_name', title: '姓名'},
					{field: 'user_phone', title: '手机'},
					{field: 'back_name', title: '银行'},
					{field: 'records_form_no', title: '订单号'},
					{field: 'records_money', title: '订单金额'},
					{field: 'records_amount', title: '实到金额'},
					//{field: 'records_cid', title: '入金账户'},
					//{field: 'records_pay_cid', title: '出金账户'},
					{field: 'records_rate', title: '费率'},
					{field: 'records_close_rate', title: '代付费'},
					{field: 'records_state', title: '状态'},
					{field: 'records_msg', title: '上游提示'},
					{field: 'records_time', title: '时间'},
					//{title: '操作', toolbar: "#bar"},
				]],
				page: true, //开启分页
				loading: true,
				limit: 20,
				done:function(res, curr, count){
					//console.log(res);
					$("#total").text(res.totalMoney);
					$("#total_fee").text(res.totalFee);
					$("#total_fee_profit").text(res.totalFeeProfit);
					$("#total_df").text(res.totaldfFee);
					$("#total_df_profit").text(res.totaldfFeeProfit);
					$("#total_profit").text(res.totalProfit);
				}
			};
			var tableIns = table.render(options);

			//搜索提交
			form.on("submit(sub)", function (res) {
				var data = res.field;
				//console.log(data);
				options["where"] = data;
				tableIns.reload(options);
				return false;
			});


			table.on('tool(table)', function (obj) { //注：tool是工具条事件名，test是table原始容器的属性 lay-filter="对应的值"
				var data = obj.data; //获得当前行数据
				var layEvent = obj.event; //获得 lay-event 对应的值（也可以是表头的 event 参数对应的值）
				//alert(obj.event);return false;
				if (layEvent === 'edit') { //查看
					location.href = "{:url('edit')}?id=" + data.upgrade_id;
				} else if (layEvent === 'del') { //查看
					layer.confirm("确定删除吗？", function () {
						$.post("{:url('dels')}", {ids: data.upgrade_id}, function (res) {
							if (res.msg != '') {
								layer.msg(res.msg);
							}
							if (res.url != '') {
								window.location.href = res.url;
							}
						});
					});

				}
			});
		});
	</script>
	</body>
</html>